/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.lucava.boatskeeper.server.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.lucava.boatskeeper.shared.dto.CategoryDto;

/**
 *
 * @author glenn
 */
public class MockCategoryDao {

    final static Map<Integer, CategoryDto> categories = new HashMap<Integer, CategoryDto>();

    static {
        for (int i = 0; i < 10; i++) {
            CategoryDto b = new CategoryDto();
            b.setId(i);
            b.setName("aCat-" + i);
            b.setId(i);
            categories.put(i, b);
        }
    }

    public static void add(CategoryDto b) {
        b.setId(categories.size() - 1);
        categories.put(b.getId(), b);
    }

    public static void save(CategoryDto b) {
        categories.get(b.getId()).setName(b.getName());
    }

    public static void delete(CategoryDto b) {

        categories.remove(b.getId());
    }

    public static CategoryDto get(Integer id) {
        return categories.get(id);
    }

    public static List<CategoryDto> getAll() {

        return new ArrayList<CategoryDto>(categories.values());
    }
}
